/*
This file is part of Docking@Home.
http://docking.gcl.cis.udel.edu
Copyright (C) 2009 University of Delaware

Docking@Home is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Docking@Home is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Docking@Home.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
	Filename: LowLevelTab.h
	Description: A tab in our gui that will control and display any of the low
		level details of the protein and ligand.
	Revision History: 
		Created - 01/02/08
	Author: Robert Keller (01/02/08 -> Current)
*/

#ifndef _LowLevelTab_h
#define _LowLevelTab_h

#include "Tab.h"
#include "CurrentView.h"
#include "Resources.h"
#include "../BioModels/BioModel.h"
#include "../ArcBall.h"
#include "../Button/Button.h"

#include <time.h>
#include <sys/timeb.h>

class LowLevelTab : public Tab
{
public:

	// Constructor / Destructor

	LowLevelTab();
	LowLevelTab(const char n[TAB_MAX_NAME_LENGTH]);
	~LowLevelTab();

	// Initialization Functions
	void init (TabWindow * tabWindow, float ls);
	void initResourceInfo(const char uname[TAB_MAX_NAME_LENGTH], const char gname[TAB_MAX_NAME_LENGTH]);

	// Required Tab Functions 

	void resizeScales (bool bFullscreen = false);

	void draw (unsigned int index, bool bFullScreen);
	void drawSelectedTab (unsigned int index);
	void drawUnselectedTab (unsigned int index);
	void drawHoveredTab (unsigned int index);
	void drawTabWindowArea ();
	void drawFullScreen ();

	void handleMouseMove (int x, int y, int left, int middle, int right);
	void handleMouseButton (int x, int y, int which, int is_down);
	void handleKeyPress (int key1, int key2);	
	void handleKeyRelease (int key1, int key2);

private:

	// Viewport Functions
	void setInnerViewport ();
	void setSSInnerViewport ();
	void setFullViewport ();

	// Change Ligand Based on bMinEner
	void changeLigandBasedOnBMinEner ();

	// Button Handling Functions
	void handleButtons ();
	void handleButtonMouseInteraction (int x, int y, bool leftClicked);
	void performButtonAction (int actionID);

	// Mouseclick Checking Functions
	bool inModelDrawingWindow(int x, int y);

	// Button Drawing Functions
	void drawButtons ();

	// Text Drawing Functions
	void drawText();

	// Model Drawing Functions
	void drawCurrentModel();
	void drawComplex(unsigned int index1, unsigned int index2);

	// List of tabs
	vector <BioModel *> models;

	// Current model / view
	
	// 0: Protein, 1: Ligand
	int currentModel;
	
	// if true, display the minener ligand, otherwise show the
	// minrmsd ligand
	bool bMinEner;

	CurrentView currentView;

	// List of buttons in tab window
	vector <Button *> bioTypeButtons;
	vector <Button *> viewChangingButtons;

	float viewChangingHeight;

	// Resouces

	Resources * resources;

	// Timing Variables
	time_t models_startTime; // Timer start time
	time_t resourceStartTime; // Timer start time

	// Ligand Text Properties
	float ligandTextScaleX;
	float ligandTextScaleY;

	float ligandPaddingX;
	float ligandPaddingY;

	// Wait time to re-parse the info files in seconds
	const int WAIT_TIME; 
	
	// Default view changing button heights
	const float DEFAULT_VIEW_CHANGING_SIZE;
};

#endif
